package com.twentyOne.ClothingLand.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.twentyOne.ClothingLand.vo.Employee;

public class AdminIMInterceptor extends AbstractInterceptor {

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		
		ActionContext actionContext = arg0.getInvocationContext();
		Map session = actionContext.getSession();
		Employee employee = (Employee) session.get("user");
		if(employee != null) {

			String[] jurisdiction = employee.getJurisdictionId().split(",");
			for (int i = 0; i < jurisdiction.length; i++) {
				if(jurisdiction[i].equals("9") || jurisdiction[i].equals("10")) {
					return arg0.invoke();
				}
			}

			return null;

		}else {
			return Action.LOGIN;
		}
		
	}

}
